import { observable, action } from 'mobx';
import { Browser,SelectPage,BrowserHrm } from 'weaver-mobile-page';
import * as Api from '../../api/UserShareSetApi'; 
export default class AddShareStore {
  // 目前搜索历史存放 localStorage，需要指定固定 id
  @observable browserDept = new Browser.Store({ route: '/userCenter/shareSet/AddShare', id: 'search-dept' });
  @observable browserSub = new Browser.Store({ route: '/userCenter/shareSet/AddShare', id: 'search-sub' });
  @observable browserRole = new Browser.Store({ route: '/userCenter/shareSet/AddShare', id: 'search-role' });
  @observable browser = new Browser.Store({ route: '/userCenter/shareSet/AddShare', id: 'search-browser' });
  @observable browserHrm = new BrowserHrm.Store({ route: '/userCenter/shareSet/AddShare', id: 'singleHrm' });
  @observable browserHrmValue = [];
  @observable browserValue = [];
  @observable browserSubValue = [];
  @observable browserDeptValue = [];
  @observable browserRoleValue = [];
  @observable browser1 = new Browser.Store({ route: '/userCenter/shareSet/AddShare' });
  @observable selectPage = new SelectPage.Store({ route: '/userCenter/shareSet/AddShare' });
  @observable browser1Value = [];

  @action
  setState = (params = {}) => {
    Object.keys(params).forEach((key) => {
      this[key] = params[key];
    });
  }
//

  @action('新增分享')
  addShareInfo = (params) => {
    Api.addShareSet(params).then(res => {
      const { status, shareToMeUserList } = res;
      if (status === '1') {
        const newState = {
          isTable: false,
          loading: false,
          haveCheck: true,
          template: {default: []},
          hasMore: false,
          data: [...shareToMeUserList],
        };
 
        

        this.shareToMeList.setState(newState);
        this.shareToMeList.updateDataSource();
      }
      this.loading = false;
      this.myAttentionLoading = false;
    })
  }

}